﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Utils;

namespace WCS.Entity
{
    /// <summary>
    /// PDA发送任务到缓存区
    /// </summary>
    [SugarTable("WCS_BarCodeInfo")]
    public class BarCodeInfo
    {
        /// <summary>
        /// 托盘号
        /// </summary>
        public string BarCode { get; set; }

        /// <summary>
        /// 站台
        /// </summary>
        public string Station { get; set; }
        public int isSolve { get; set; }

        /// <summary>
        /// 数据库连接对象
        /// </summary>
        static SqlSugarDapper _SqlSugarDapper = SqlSugarDapper.GetDbContext();

        /// <summary>
        /// 获取托盘是否有货
        /// </summary>
        /// <param name="material"></param>
        /// <returns></returns>
        public static BarCodeInfo GetBarCodeIsGood(string barCode)
        {
            return _SqlSugarDapper.DB.Queryable<BarCodeInfo>().Where(w => w.BarCode == barCode).First();
        }

        /// <summary>
        /// 添加托盘信息
        /// </summary>
        /// <param name="material"></param>
        /// <returns></returns>
        public static void AddBarCodeInfo(BarCodeInfo barCodeInfo)
        {
            _SqlSugarDapper.DB.Insertable(barCodeInfo).ExecuteCommand();
        }

        /// <summary>
        /// 根据托盘号删除信息
        /// </summary>
        /// <param name="material"></param>
        /// <returns></returns>
        public static void DeleteBarCodeInfo(string barCode)
        {
            //根据物料号查询这个物料在那个仓库的第几层
            _SqlSugarDapper.DB.Deleteable<BarCodeInfo>().Where(w => w.BarCode == barCode && w.isSolve == 1).ExecuteCommand();
        }
    }
}
